package com.prp.keywords_search_statistic;

import java.util.List;
import java.util.Set;

import com.prp.db.po.SubjectRecommendation;

/**
 * @author Administrator
 * 
 */
public class ClientThread extends Thread implements ResultProcessor {

	String keyword;
	Integer userID;//用户ID
	Integer start;//用户希望从第几条记录开始搜索
	Integer count;//用户希望返回多少条记录
	
	int id;
	
	static Integer temp = 0;
	
	/**
	 * main
	 * @param args
	 */
	public static void main(String[] args){
		for( int i = 0; i < 100 ; i++){
			ClientThread clientThread = new ClientThread(String.valueOf(i),1,0,40);
			clientThread.id = i;
			clientThread.start();
		}
	}
	
	public ClientThread(String keyword, Integer userID, Integer start, Integer count){
		this.keyword = keyword;
		this.userID = userID;
		this.start = start;
		this.count = count;
	}
	public void run() {
		SearchServer.service(keyword, this, userID, start, count);
	}

	/**
	 * SubjectRecommendation是主题帖类,SearchServer的搜索线程会回调函数process方法，
	 * 所以在process方法中对返回结果进行使用
	 */
	@Override
	public void process(String keyword, Set<Integer> entityId,
			List<SubjectRecommendation> list) {
		temp++;
//		System.out.print(temp+ "  ");
		// 参数即为需要的主题贴
		System.out.println(id + " 结果返回了，主题帖子数目为"+list.size());

	}

}
